package com.qf.util;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;

public class ElasticsearchUtil {


    // 返回和ES服务交互的客户端对象
    public static RestHighLevelClient getClient(){

        // 如果大家使用的是5.x的ES,一般情况Java操作ES时,会采用91/300的端口,图形化界面操作,依然是9200
        HttpHost httpHost = new HttpHost("192.168.41.41",9200);

        RestClientBuilder restClientBuilder = RestClient.builder(httpHost);

        RestHighLevelClient client = new RestHighLevelClient(restClientBuilder);

        return client;
    }

}
